<template>
  <view class="container">
    <div style="width: 95%; margin-left: 2.5%">
      <div
        style="
          display: flex;
          align-items: center;
          justify-content: space-between;
        "
      >
        <div style="color: #1a512c">
          <div style="font-size: 25px; font-weight: 700">您好1! ###</div>
          <div style="height: 15rpx"></div>
          <div>您加入该系统368天</div>
          <div style="height: 5rpx"></div>
          <div>已累计接受工单1235次</div>
        </div>
        <div class="carStop" @click="carStop">
          <!-- <image src="../../static/p.jpg" mode="scaleToFill" /> -->
          <div>车辆报停</div>
        </div>
      </div>
      <div style="height: 10px"></div>
      <!-- 边框 -->
      <view class="card">
        <div style="height: 20px"></div>
        <div
          style="
            color: #1a512c;
            display: flex;
            align-items: center;
            justify-content: space-between;
            text-align: center;
          "
        >
          <div style="width: 48%">
            <div>
              <text style="font-size: 50px; font-weight: 900">30</text>
              <text style="font-weight: 500">t</text>
            </div>
            <div>今日已收集牛粪</div>
          </div>
          <div style="width: 48%">
            <text style="font-size: 50px; font-weight: 900">30</text>
            <text style="font-weight: 500">m³</text>
            <div>今日已收集污水</div>
          </div>
        </div>
        <div style="height: 20px"></div>
      </view>
      <div style="height: 10px"></div>
      <!-- 收运车到达 -->
      <div class="center-bg">
        <div style="height: 15px"></div>
        <div style="width: 90%; margin-left: 5%">
          当前收运车到达处理厂，正在卸料。
        </div>
        <div style="height: 15px"></div>
      </div>
      <div style="height: 10px"></div>
      <div style="background: #fff; border-radius: 10px">
        <div style="height: 10px"></div>
        <!-- eCharts -->
        <view class="charts-box">
          <qiun-data-charts type="column" :opts="opts" :chartData="chartData" />
        </view>
        <div style="height: 10px"></div>
      </div>
      <!-- 底部 -->
      <div style="height: 10px"></div>
      <div class="foot-card">
        <div style="height: 15px"></div>
        <div
          style="
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 95%;
            margin-left: 2.5%;
          "
        >
          <div>
            <div style="color: #1a512c; font-weight: 500">
              <div v-if="flag">您当前有1条手动派发工单待接</div>
              <div v-if="!flag">已到达收运点，请填报节点流程!</div>
            </div>
            <div style="color: #c5b46d; font-size: 14px; font-weight: 500">
              今日累接单2次
            </div>
          </div>
          <div class="look" v-if="flag" @click="looks">查看</div>
          <div class="looks" v-if="!flag" @click="submit">填报</div>
        </div>
        <div style="height: 15px"></div>
      </div>
    </div>
  </view>
</template>
<script>
import qiunDataCharts from '@/pagesScreen/subpackageuni/qiun-data-charts/components/qiun-data-charts/qiun-data-charts.vue'
export default {
  components: { qiunDataCharts },
  data() {
    return {
      flag:false,
      chartData: {},
      opts: {
        color: [
          "#1890FF",
          "#91CB74",
          "#FAC858",
          "#EE6666",
          "#73C0DE",
          "#3CA272",
          "#FC8452",
          "#9A60B4",
          "#ea7ccc",
        ],
        padding: [15, 15, 0, 5],
        enableScroll: false,
        legend: {},
        xAxis: {
          disableGrid: true,
        },
        yAxis: {
          data: [
            {
              min: 0,
            },
          ],
        },
        extra: {
          column: {
            type: "group",
            width: 30,
            activeBgColor: "#000000",
            activeBgOpacity: 0.08,
          },
        },
      },
    };
  },
  methods: {
    looks(){
      uni.navigateTo({ url: '/pagesDriver/system/workOrder' })
    },
    submit(){
      uni.navigateTo({ url: '/pagesDriver/system/filling' })
    },
    getServerData() {
      //模拟从服务器获取数据时的延时
      setTimeout(() => {
        //模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
        let res = {
          categories: ["2018", "2019", "2020", "2021", "2022", "2023"],
          series: [
            {
              name: "目标值",
              data: [35, 36, 31, 33, 13, 34],
            },
            {
              name: "完成量",
              data: [18, 27, 21, 24, 6, 28],
            },
          ],
        };
        this.chartData = JSON.parse(JSON.stringify(res));
      }, 500);
    },
    carStop(){
      uni.navigateTo({ url: '/pagesDriver/system/carStop' })
    }
  },
  onShow() {
    uni.hideHomeButton();
  },
  onReady() {
    this.getServerData();
  },
};
</script>
<style lang="scss">
.container {
  background: #f6f3e7;
  height: 100vh;
}
.carStop {
  text-align: center;
}
.carStop image {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}
.card {
  border: 3px solid #1a512c;
  border-radius: 10px;
}
.center-bg {
  background: #1a512c;
  color: #fff;
  // width: 95%;
  // margin-left: 2.5%;
  border-radius: 10px;
}
.charts-box {
  width: 100%;
  height: 230px;
}
.foot-card {
  background: #fff;
  border-radius: 10px;
}
.look {
  background: #1a512c;
  color: #fff;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.looks {
  background: #D0463F;
  color: #fff;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
